<template>
  <div id="contain">
    <div class="searchBox">
      <input type="text" class="inp" v-model="keyWord" />
      <span class="sp" @click="getlist"><i class="el-icon-search"></i></span>
    </div>
    <div v-if="noInfo">
      <div v-show="noInfo">
        <div class="noSearchDiv">{{ noInfo }}</div>
      </div>
    </div>
    <div v-else>
      <div
        v-for="(item, index) in infolist"
        :key="index"
        style="width: 255px; height: 220px; float: left; margin: 15px"
        @click="godetails(item.hotelId)"
      >
        <img :src="item.pic" alt="" style="width: 255px; height: 180px" />
        <p class="introtext">{{ item.name }}</p>
      </div>
      <div style="clear: both"></div>
      <div class="page">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="page"
            :page-sizes="[12, 16]"
            :page-size="limit"
            layout="sizes, prev, pager, next"
            :total="totalCount"
            background
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
// import Search from "@/components/Search.vue";
export default {
  data() {
    return {
      infolist: [],
      page: 1,
      limit: 12,
      keyWord: "",
      noInfo: ""
    };
  },
  mounted() {
    this.getlist();
  },
  methods: {
    handleSizeChange(val) {
      this.limit = val;
      this.getlist();
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getlist();
    },
    getlist() {
      this.$axios({
        method: "post",
        url: "/static/hotel/list",
        data: { page: this.page, limit: this.limit , keyword: this.keyWord },
      }).then((res) => {
        console.log(res);
        if (res.data.code === 0) {
          if (res.data.page.regard[0]) {
            this.infolist = res.data.page.regard;
            this.noInfo = ""
          } else {
            this.noInfo = "没有找到相关数据"
          }
        }
      });
    },
    godetails(hotelId) {
      this.$router.push({ path: "jiudiandetails", query: { hotelId: hotelId } });
    },
  },
};
</script>
<style  scoped>
.searchBox {
  width: 800px;
  height: 70px;
  margin: 4px auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.inp {
  display: inline-block;
  width: 720px;
  height: 60px;
  border-radius: 5px;
  font-size: 18px;
  padding-left: 10px;
  border: 2px solid #ff9d00;
  -webkit-appearance: none;
  -moz-appearance: none;
  outline: 0;
}
.sp {
  display: inline-block;
  width: 60px;
  height: 60px;
  background-color: #ff9d00;
  border-radius: 10%;
  text-align: center;
}
.el-icon-search {
   font-size: 30px;
   color: white;
   text-align: center;
   line-height: 60px;
 }
.noSearchDiv {
  width: 300px;
  margin: 100px auto;
  font-size: 24px;
}
</style>>
